// 路由配置文件
import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router';
// 这里的路径引用可能会报错，可以参考文章【项目配置文件】每个文件的作用，配置过程中遇到的问题及解决办法
import HomeView from '@/views/HomeView.vue';
import CameraViewer from '@/views/CameraViewer.vue';
import AnalysisView from '@/views/AnalysisView.vue';

import TestView from '@/views/TestView.vue';
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'home',
    meta: { title: '地图平台' },
    component: HomeView,
    // component: () => import("@/views/home/index.vue"),
    // children: []
  },

  {
    path: '/test',
    name: 'test',
    meta: { title: '地图平台' },
    component: TestView,
  },

  // {
  //   path: '/camera',
  //   name: 'camera',
  //   meta: { title: '地图平台' },
  //   component: CameraViewer,
  //   // component: () => import("@/views/home/index.vue"),
  //   // children: []
  // },
  //
  // {
  //   path: '/analysis',
  //   name: 'analysis',
  //   meta: { title: '地图平台' },
  //   component: AnalysisView,
  // },


  // 添加其他路由
];

// @ts-ignore
const router = createRouter({
  history: createWebHashHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
  routes: constantRoutes,
  // 刷新时，滚动条位置还原
  scrollBehavior(savedPosition: any) {
    if (savedPosition) {
      return savedPosition;
    }
    return { top: 0 };
  },
});

export default router;
